package org.jeecg.modules.htxincailiao.library.entity;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.math.BigDecimal;
import java.util.List;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.common.util.oConvertUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @Description: ht_library
 * @Author: jeecg-boot
 * @Date:   2022-07-19 10:15:47
 * @Version: V1.0
 */
@Data
@TableName("ht_library")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="ht_library对象", description="ht_library")
public class HTLibrary implements Serializable {
    private static final long serialVersionUID = 1L;

	/**主键ID*/
	@TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键ID")
    private String id;
	/**分类ID*/
	@Excel(name = "分类", width = 15, dictTable = "ht_library_category", dicText = "name", dicCode = "id")
	@Dict(dictTable = "ht_library_category", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "分类ID")
    private String categoryId;
	/**企业*/
	@Excel(name = "企业", width = 15, dictTable = "ht_merchant", dicText = "enterprise_name", dicCode = "id")
	@Dict(dictTable = "ht_merchant", dicText = "enterprise_name", dicCode = "id")
    @ApiModelProperty(value = "企业")
    private String shopId;

	/**
	 * 视频
	 */
	//@Excel(name = "视频", width = 15)
	@ApiModelProperty(value = "视频")
	private String videoUrls;

	/**标题*/
	@Excel(name = "标题", width = 15)
    @ApiModelProperty(value = "标题")
    private String archiveName;
	/**预览文件（.pdf）*/
	//@Excel(name = "预览文件（.pdf）", width = 15)
    @ApiModelProperty(value = "预览文件（.pdf）")
    private String previewArchiveUrl;
	/**资料Url（.pdf）*/
	//@Excel(name = "资料Url（.pdf）", width = 15)
    @ApiModelProperty(value = "资料Url（.pdf）")
    private String archiveUrl;
	/**资料下载权限*/
	@Excel(name = "资料下载权限", width = 15, dicCode = "library_archive_download_permission")
	@Dict(dicCode = "library_archive_download_permission")
    @ApiModelProperty(value = "资料下载权限")
    private Integer archiveDownloadPermission;
	/**副标题*/
	@Excel(name = "副标题", width = 15)
    @ApiModelProperty(value = "副标题")
    private String subname;
	/**排序*/
	@Excel(name = "排序", width = 15)
    @ApiModelProperty(value = "排序")
    private Integer sort;
	/**首页排序*/
	@Excel(name = "首页排序", width = 15)
    @ApiModelProperty(value = "首页排序")
    private Integer homeSort;
	/**关键字*/
	@Excel(name = "关键字", width = 15)
    @ApiModelProperty(value = "关键字")
    private String keywords;
	/**摘要*/
	@Excel(name = "摘要", width = 15)
    @ApiModelProperty(value = "摘要")
    private String archiveAbstract;
	/**详细内容*/
	//@Excel(name = "详细内容", width = 15)
    @ApiModelProperty(value = "详细内容")
    private String content;
	/**主图*/
	//@Excel(name = "主图", width = 15)
    @ApiModelProperty(value = "主图")
    private String cover;
	/**图片集*/
	//@Excel(name = "图片集", width = 15)
    @ApiModelProperty(value = "图片集")
    private String images;
	/**成本价*/
	@Excel(name = "成本价", width = 15)
    @ApiModelProperty(value = "成本价")
    private BigDecimal costPrice;
	/**市场价（原价）*/
	@Excel(name = "市场价（原价）", width = 15)
    @ApiModelProperty(value = "市场价（原价）")
    private BigDecimal marketPrice;
	/**零售价*/
	@Excel(name = "零售价", width = 15)
    @ApiModelProperty(value = "零售价")
    private BigDecimal retailPrice;
	/**售出数量*/
	@Excel(name = "售出数量", width = 15)
    @ApiModelProperty(value = "售出数量")
    private Integer saleAmount;
	/**库存数量*/
	@Excel(name = "库存数量", width = 15)
    @ApiModelProperty(value = "库存数量")
    private Integer stockAmount;
	/**是否为首页推荐 0-不推荐 1-推荐*/
	@Excel(name = "是否为首页推荐", width = 15, dicCode = "is_home_recommended")
	@Dict(dicCode = "is_home_recommended")
    @ApiModelProperty(value = "是否为首页推荐 0-不推荐 1-推荐")
    private Integer isHomeRecommended;
	/**库存单元ID*/
	@Excel(name = "库存单元ID", width = 15)
    @ApiModelProperty(value = "库存单元ID")
    private String unitId;
	/**SKU*/
	@Excel(name = "SKU", width = 15)
    @ApiModelProperty(value = "SKU")
    private String sku;
	/**产地*/
	@Excel(name = "产地", width = 15)
    @ApiModelProperty(value = "产地")
    private String originPlace;
	/**是否为企业首页推荐 0-不推荐 1-推荐*/
	//@Excel(name = "是否为企业首页推荐 0-不推荐 1-推荐", width = 15, dicCode = "is_enterprise_home_recommended")
	@Dict(dicCode = "is_enterprise_home_recommended")
    @ApiModelProperty(value = "是否为企业首页推荐 0-不推荐 1-推荐")
    private String isEnterpriseHomeRecommended;
	/**资料状态（0-仓库中 1-下架，2 上架）*/
	@Excel(name = "资料状态", width = 15, dicCode = "library_status")
	@Dict(dicCode = "library_status")
    @ApiModelProperty(value = "资料状态（0-仓库中 1-下架，2 上架）")
    private String libraryStatus;
	/**审批状态*/
	@Excel(name = "审批状态", width = 15, dicCode = "audit_status")
	@Dict(dicCode = "audit_status")
    @ApiModelProperty(value = "审批状态")
    private String auditStatus;
	/**审批人*/
	@Excel(name = "审批人", width = 15)
    @ApiModelProperty(value = "审批人")
    private String auditUsername;
	/**审批意见*/
	@Excel(name = "审批意见", width = 15)
    @ApiModelProperty(value = "审批意见")
    private String auditComments;
	/**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
	/**创建时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
	/**更新人*/
    @ApiModelProperty(value = "更新人")
    private String updateBy;
	/**更新时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;


	@TableField(exist = false)
	@ApiModelProperty(value = "分类名")
	private String categoryName;

	@TableField(exist = false)
	private Integer pageNo;

	@TableField(exist = false)
	private Integer pageSize;

	@TableField(exist = false)
	private String[] imageList;

	public String[] getImageList() {
		String[] empty = new String[]{};

		if (oConvertUtils.isEmpty(images)) {
			return new String[]{cover};
		} else {
			List<String> combineList = new ArrayList<>();
			combineList.add(cover);

			String[] imageItems = images.split(",");
			List<String> imageList = Arrays.asList(imageItems);
			if (oConvertUtils.isNotEmpty(imageList) && !imageList.isEmpty()) {
				combineList.addAll(imageList);
			}

			return combineList.toArray(new String[0]);
		}
	}

	@TableField(exist = false)
	private String[] videoList;

	public String[] getVideoList() {
		String[] empty = new String[]{};

		if (oConvertUtils.isNotEmpty(videoUrls)) {
			String[] videoItems = videoUrls.split(",");

			List<String> list = Arrays.asList(videoItems);

			return list.toArray(new String[0]);
		}

		return empty;
	}

	@TableField(exist = false)
	private String[] mediaList;

	public String[] getMediaList() {
		List<String> list = new ArrayList<>();

		if (oConvertUtils.isNotEmpty(videoUrls)) {
			String[] videoItems = videoUrls.split(",");
			if (oConvertUtils.isNotEmpty(videoItems)) {
				list.addAll(Arrays.asList(videoItems));
			}
		} else {
			list.add(cover);
		}

		if (oConvertUtils.isNotEmpty(images)) {
			String[] imageItems = images.split(",");
			List<String> imageList = Arrays.asList(imageItems);
			if (oConvertUtils.isNotEmpty(imageList) && !imageList.isEmpty()) {
				list.addAll(imageList);
			}
		}

		return list.toArray(new String[0]);
	}


	@TableField(exist = false)
	private String poster;

	public String getPoster() {
		return cover;
	}

	/**SEO关键字*/
	@Excel(name = "SEO关键字", width = 15)
	@ApiModelProperty(value = "SEO关键字")
	private String seoKeywords;


	/**SEO描述*/
	@Excel(name = "SEO描述", width = 15)
	@ApiModelProperty(value = "SEO描述")
	private String seoDescription;

}
